<?php
/**
 * Model_InfoCommon
 *
 * @package    model
 */
class Model_InfoCommon extends Model_Mine {
	
	protected $_name = 'info_common';
	protected static $_type = array(1=>'text',2=>'single',3=>'mutli');
	
	public static function get_type($name){
		$name = strtolower(trim($name));
		return array_search($name, self::$_type);
	}
	
	public function findByWhere($where){
		$filter = array();
		$filter['where'] = $where;
		$sql = $this->select($filter);
		return $this->fetchRow($sql);
	}
	
	static function getMassAll(){
		$infoModel = new Model_InfoCommon;
		$infoList  = array();
		$type 	   = $_GET['type'] ? $_GET['type'] : 1;
		
		$infoList  = $infoModel->findAll("info_type='$type' and is_mass=1 and state=1");
		
		if($infoList){
			foreach ($infoList as &$val){
				$val['info_content'] = cut_str($val['info_content'],10);
				$val['info_title']	 = cut_str($val['info_title'],10);
			}
		}
		return $infoList;
	}
}

